// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

package com.yztag;


import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.log4j.Logger;

// Referenced classes of package com.lbs.cp.taglib:
//            ViewTableTag, Formatter

public class Jqcol extends BodyTagSupport/*TagSupport*/ {
    protected String name;//字段名字
    protected String index;//传到服务器端用来排序用的列名称
    protected String width;//列宽度
    protected String align;// 对齐方式；
    protected String sortable;//  是否可以排序
    protected String hidden;//  是否隐藏
    protected String stype;//查询类型
    protected String formatter;//数据格式
    protected String type;//数据类型：参数或者字符
    protected String sopt;//搜索类型


    protected String editoptions;//格式数据，如：下拉框
    protected String editable;//是否为编辑字段
    protected String editsize;//编辑字段长度
    protected String editrules;//编辑规则，例如：required: true
    protected String formoptions;//编辑格式

    //	protected String lqflookupcol;//Lookup类型到代码表 20150625
    public Jqcol() {
    }
    private static Logger log = Logger.getLogger(Jqcol.class);

    public int doStartTag()
            throws JspException {
        StringBuffer stringbuffer = new StringBuffer("");
        stringbuffer.append("{name:'" + name + "',index:'" + index + "'");
        if (width != null) {
            stringbuffer.append(",width:'" + width + "'");
        }
        if (align != null && !align.equals("")) {
            stringbuffer.append(",align:'" + align + "'");
        } else {
            stringbuffer.append(",align:'center'");
        }
        if (hidden != null) {
            stringbuffer.append(",hidden:" + hidden + "");
        }
        if (sortable != null) {
            stringbuffer.append(",sortable:'" + sortable + "'");
        }
        if (editable != null) {
            stringbuffer.append(",editable:" + editable);
        }
        if (editable != null && editable.equals("true") && ((stype != null && stype.equals("select")) || type != null)) {
            stringbuffer.append(",edittype:'select'");
        }
        if ((stype != null && stype.equals("select"))) {
            stringbuffer.append(",stype: 'select',formatter:'select'");
            stringbuffer.append(",searchoptions:{searchhidden:true,sopt: ['eq', 'ne']}");
        } else if (stype != null && stype.equals("date")) {
            stringbuffer.append(",searchoptions:{searchhidden:true,dataInit:datePick");
            if (sopt != null && !"".equals(sopt)) {
                stringbuffer.append(",sopt:[" + sopt + "]");
            }
            stringbuffer.append("}");
            if (editable != null && editable.equals("true")) {
                stringbuffer.append(",editoptions:{dataInit:datePick");
                if (editsize != null) {
                    stringbuffer.append(",size:'" + editsize + "'");
                }
                stringbuffer.append("}");
            }

        } else {
            if (sopt != null && !"".equals(sopt)) {
                stringbuffer.append(",searchoptions:{searchhidden:true,sopt: [" + sopt + "]}");
            }
        }
        if (editoptions != null) {
            stringbuffer.append(",editoptions: { value: {'':''," + editoptions + "");
            stringbuffer.append("}");
            if (editsize != null) {
                stringbuffer.append(",size:'" + editsize + "'");
            }
            stringbuffer.append("}");
        }
        if (type != null && !type.equals("")) {
            stringbuffer.append(",formatter:'select'");
            stringbuffer.append(",stype: 'select'");
            stringbuffer.append(",editoptions: { value: {'':''");
            TreeMap<String, TreeMap> treeMap = (TreeMap<String, TreeMap>) pageContext.getServletContext().getAttribute("parameter");
            TreeMap<String, String> treeMapp = (TreeMap<String, String>) treeMap.get(type);
            if (treeMapp != null) {
                Iterator iter = treeMapp.entrySet().iterator();
                while (iter.hasNext()) {
                    Map.Entry entry = (Map.Entry) iter.next();
                    Object key = entry.getKey();
                    stringbuffer.append(",'" + key + "':'" + entry.getValue() + "'");

                }

                stringbuffer.append("}");
                if (editsize != null) {
                    stringbuffer.append(",size:'" + editsize + "'");
                }
                stringbuffer.append("}");
            }
        }
        if (editrules != null) {
            stringbuffer.append(",editrules:{" + editrules + "}");
        }
        if (formatter != null) {
            stringbuffer.append(",formatter:" + formatter + "");
        }
        if (formoptions != null) {
            stringbuffer.append(",formoptions:{" + formoptions + "}");
        }

        if (stype == null && type == null) {
            if (editsize != null) {
                stringbuffer.append(",editoptions:{size:'" + editsize + "'}");
            }
        }
        stringbuffer.append("},");
        JspWriter jw = this.pageContext.getOut();
        try {
            jw.write(stringbuffer.toString());
        } catch (IOException e) {
            // TODO Auto-generated catch block
        	log.error("", e);
        }
        return SKIP_PAGE;
    }
    //不对!
    //    public int  doEndTag(){
    //
    //    	if (lqflookupcol!= null && lqflookupcol.trim().length()>0){
    //        	TreeMap<String, TreeMap> treeMap=(TreeMap<String, TreeMap>)pageContext.getServletContext().getAttribute("parameter");
    //        	TreeMap<String, String> treeMapp=(TreeMap<String, String>)treeMap.get(type);
    //        		if(treeMapp!=null){
    //        	    	JspWriter jw = this.pageContext.getOut();
    //        	    	try {
    //						jw.print("dddddddddddd");
    //					} catch (IOException e) {
    //						e.printStackTrace();
    //					}
    //        		}
    //
    //    	}
    //    	return EVAL_PAGE;
    //    }

    public void setAlign(String align) {
        this.align = align;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSortable(String sortable) {
        this.sortable = sortable;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public void setHidden(String hidden) {
        this.hidden = hidden;
    }

    public void setStype(String stype) {
        this.stype = stype;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setFormatter(String formatter) {
        this.formatter = formatter;
    }

    public void setEditoptions(String editoptions) {
        this.editoptions = editoptions;
    }

    public void setSopt(String sopt) {
        this.sopt = sopt;
    }

    public void setEditable(String editable) {
        this.editable = editable;
    }

    public void setEditsize(String editsize) {
        this.editsize = editsize;
    }

    public void setEditrules(String editrules) {
        this.editrules = editrules;
    }

    public void setFormoptions(String formoptions) {
        this.formoptions = formoptions;
    }

/*	public String getLqflookupcol() {
        return lqflookupcol;
	}

	public void setLqflookupcol(String lqflookupcol) {
		this.lqflookupcol = lqflookupcol;
	}
*/


}
